package com.onepice.mlp.core.serviceImpl;

import com.onepice.mlp.core.service.GroupdService;
import com.onepice.mlp.data.dao.GroupdDao;
import com.onepice.mlp.data.entity.Groupd;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

/**
 * @author FireWang
 * @date 2022/07/11 23:25:03
 */
@Service
@AllArgsConstructor
@Transactional
public class GroupdServiceImpl implements GroupdService {
    private GroupdDao groupdDao;

    @Override
    public List<Groupd> getAll() {
        return groupdDao.findAll();
    }

    @Override
    public Groupd getById(Integer id) {
        Optional<Groupd> groupd = groupdDao.findById(id);
        return groupd.get();
    }

    @Override
    public void insert(Groupd groupd) {
        groupdDao.save(groupd);
    }

    @Override
    public void update(Groupd groupd) {
        groupdDao.save(groupd);
    }

    @Override
    public void deleteById(Integer id) {
        groupdDao.deleteById(id);
    }
}
